# Time: 2021/07/04
# Author: ZhaoKugua


import base64
from time import sleep

if __name__ == '__main__':
    print("或许我们可以试着反向给他加密过去！")
    password = input('请输入要加密的内容:\n>>>')
    print('1.base64加密')
    text = base64.b64encode(bytes(password, encoding='utf-8')).decode('utf-8')
    print(text)
    sleep(0.5)
    if text[-2:] == '==':
        text = text[0:-2]
    print('2.拆分字母')
    char_list = []
    for char in text:
        char_list.append(char)
    print(char_list)
    sleep(0.5)
    print('3.转换为十进制的ascii码')
    i = 0
    for char in char_list:
        char_list[i] = ord(char)
        i += 1
    print(char_list)
    sleep(0.5)
    print('4.转换为8位二进制')
    i = 0
    for char in char_list:
        char_list[i] = str(bin(char))[2:]
        if len(char_list[i]) < 8:
            char_list[i] = '0' * (8-len(char_list[i])) + char_list[i]
        i += 1
    print(char_list)
    sleep(0.5)
    print('5.合并成文本')
    text = ''
    for char_ord in char_list:
        text = text + char_ord
    text = '《' + text + '==》'
    print(text)
    


